import type { AppRouteRecordRaw, AppRouteModule } from '/@/router/types';

import { PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '/@/router/routes/basic';

import { PageEnum } from '/@/enums/pageEnum';
import { t } from '/@/hooks/web/useI18n';
import { LAYOUT } from '/@/router/constant';

const modules = import.meta.globEager('./modules/**/*.ts');

const routeModuleList: AppRouteModule[] = [];

Object.keys(modules).forEach((key) => {
  const mod = modules[key].default || {};
  const modList = Array.isArray(mod) ? [...mod] : [mod];
  routeModuleList.push(...modList);
});

export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList];

export const RootRoute: AppRouteRecordRaw = {
  path: '/',
  name: 'Root',
  redirect: PageEnum.BASE_HOME,
  meta: {
    title: 'Root',
  },
};

export const LoginRoute: AppRouteRecordRaw = {
  path: '/login',
  name: 'Login',
  component: () => import('/@/views/sys/login/Login.vue'),
  meta: {
    title: t('routes.basic.login'),
  },
};
export const ProfileRoute: AppRouteRecordRaw = {
  path: '/profile',
  component: LAYOUT,
  name: 'Profile',
  meta: {
    title: '个人中心',
    hidden: true,
  },
  children: [
    {
      path: 'index',
      component: () => import('/@/views/sys/profile/index.vue'),
      name: 'UserProfile',
      meta: {
        canTo: true,
        hidden: true,
        noTagsView: false,
        icon: 'ant-design:user-outlined',
        title: '个人中心',
      },
    },
    // {
    //   path: 'notify-message',
    //   component: () => import('@/views/system/notify/my/index.vue'),
    //   name: 'MyNotifyMessage',
    //   meta: {
    //     canTo: true,
    //     hidden: true,
    //     noTagsView: false,
    //     icon: 'ant-design:bell-outlined',
    //     title: '站内信',
    //   },
    // },
  ],
};
// Basic routing without permission
export const basicRoutes = [
  LoginRoute,
  RootRoute,
  ProfileRoute,
  REDIRECT_ROUTE,
  PAGE_NOT_FOUND_ROUTE,
];
